0 PRINT"[147] BASIC MONITOR" 1 PRINT"CODED FOR COMMODORE 64 BY" 2 PRINT" W. MURRAY STROME" 3 PRINT " SPACES IGNORED IN DISSASSEMBLY" 4 PRINT" 'D' FOR DISASSEMBLE " 5 PRINT" 'A' FOR ASSEMBLE" 6 PRINT" 'Q' TO EXIT PROGRAM" 8 PRINT" 'END' STOPS ASSEMBLY" 10 PRINT" PRESS SPACE BAR TO STOP" 11 PRINT" DISASSEMBLY" 13 PRINT"" 14 PRINT" START OF ASSEMBLY ADDRESS" 15 PRINT" MUST BE A FOUR DIGIT NUMBER" 16 PRINT" IN HEXADECIMAL" 17 PRINT" USE DEVICE #3 FOR SCREEN," 18 PRINT" #4 FOR PRINTER" 20 (null) TO 2000 100 L=L/4096:FOR J=1 TO 4:L%=L:PRINTCHR$(48+L%-(L%>9)*7);:L=16*(L-L%) 150 NEXT:RETURN 200 L=L/16:FOR J=1 TO 2:L%=L:PRINTCHR$(48+L%-(L%>9)*7);:L=16*(L-L%):NEXT:RETURN 300 L=0:FOR J= 1 TO 4:L%=ASC(MID$(L$,J)):L=16*L+L%-48+(L%>64)*7:NEXT:RETURN 350 L=0:FOR J=1 TO 2 :L%=ASC(MID$(L$,J)):L=16*L+L%-48+(L%>64)*7:NEXT:RETURN 400 FOR K=2 TO 1 STEP -1:L=PEEK(CA+K):GOSUB 200:NEXT:RETURN 500 L=PEEK(CA+1):GOSUB 200: RETURN 600 PRINT"(";:GOSUB 400: PRINT")";:RETURN: REM INDIRECT JUMP 610 GOSUB 500:PRINT",Y";:RETURN:REM ZERO PAGE, INDEXED BY Y REGISTER 620 PRINT"(";:GOSUB 500: PRINT",X)";:RETURN: REM INDEXED INDIRECT (ZERO PAGE,X) 630 PRINT"(";:GOSUB 500:PRINT",Y)";:RETURN: REM INDIRECT INDEXED (ZERO PAGE,Y) 640 L=PEEK(CA+1): IF L>127 THEN L=L-256 642 L=CA+2+L:GOSUB 100:PRINT;:RETURN:REM RELATIVE BRANCH 650 GOSUB 400: PRINT",Y";:RETURN:REM ABSOLUTE, INDEXED BY Y REGISTER 660 PRINT"#";: GOSUB 500:PRINT;:RETURN: REM IMMEDIATE 670 GOSUB 400: PRINT",X";:RETURN: REM ABSOLUTE, INDEXED BY X REGISTER 680 GOSUB 500: PRINT",X";:RETURN: REM ZERO PAGE, INDEXED BY X REGISTER 690 GOSUB 500: PRINT;:RETURN: REM ZERO PAGE 700 GOSUB 400: PRINT;:RETURN: REM ABSOLUTE 710 PRINT;:RETURN: REM IMPLIED AND ACCUMULATOR 800 REM ASSEMBLER ROUTINES 805 IF L=3 THEN M=11:RETURN: REM IMPLIED 810 IF L=5 THEN M= 9:RETURN: REM ZERO PAGE 815 IF L=6 THEN M= 6:RETURN: REM IMMEDIATE 820 L$=MID$(AS$,7,1) 825 IF L$="X" THEN M=8:RETURN: REM ZERO PAGE,X 830 IF L$="Y" THEN M=1:RETURN: REM ZERO PAGE,Y 835 IF L$="," THEN M=2:RETURN: REM INDIRECT,X 840 IF L$=")" THEN M=3:RETURN: REM INDIRECT,Y 845 L$=RIGHT$(AS$,1) 850 IF L$="X" AND L=10 THEN M=7: RETURN: REM ABSOLUTE,X 855 IF L$="Y" AND L=10 THEN M=5:RETURN: REM ABSOLUTE,Y 860 IF L$=")" AND L=10 THEN M=0:RETURN: REM ABSOLUTE INDIRECT 865 IF LEFT$(AS$,1)="B" AND MID$(AS$,2,1)<>"I" THEN M=4:RETURN: REM BRANCH 870 IF L=7 THEN M=10:RETURN: REM ABSOLUTE 875 PRINT"MODE ?":M=12:RETURN: REM CATCH ALL OTHER INCORRECT ENTRIES 900 P=5:L=4:GOSUB 960: RETURN 905 P=4:L=2:GOTO 960 910 P=5:L=2:GOTO 960 915 P=5:L=2:GOTO 960 920 P=4:L=4:GOSUB 960:GOSUB 300 921 L=L-CA-2: IF L>127 OR L<-128 THEN PRINT "BRANCH?":M=12:RETURN 922 IF L<0 THEN L=L+256 923 RETURN 925 P=4:L=4:GOTO 960 930 P=5:L=2:GOTO 960 935 P=4:L=4:GOTO 960 940 P=4:L=2:GOTO 960 945 P=4:L=2:GOTO 960 950 P=4:L=4:GOTO 960 960 L$=MID$(AS$,P,L): RETURN 2000 DIM OP$(255),M%(255):SP$=" " 2010 FOR J=0 TO 150: REM TOTOAL OF 151 DIFFERENT OPCODE/MODE COMBINATIONS 2020 READ OP,OP$(OP),M%(OP) 2030 NEXT J 2500 L$="":POKE198,0:INPUT "ASSEMBLE OR DISSAMBLE";L$ 2510 IF L$="A" GOTO 4000 2512 IF L$="Q" THEN END: REM QUIT 2513 IFL$<>"D" THEN GOTO 2500 3000 INPUT "DISASSEMBLE FROM";L$ 3005 GOSUB 300: CA=L 3006 INPUT"DISASSEMBLE TO";L$ 3007 GOSUB 300:CE=L 3008 INPUT"DEVICE#";N 3009 OPEN N,N:CMD N, 3010 L=CA: PRINT L;LEFT$(SP$,7-LEN(STR$(L)));: GOSUB 100 3015 P=PEEK(CA):M=M%(P) 3020 IF OP$(P)<>"" THEN 3025 3022 L=P:PRINT" ";:GOSUB 200: PRINT" ???";:NB=1:GOTO3065 3025 NB=2:IF M=0 OR M=5 OR M=7 OR M=10 THEN NB=3 3030 IF M=11 THEN NB=1 3035 PRINT" "; 3040 FOR K=0 TO NB-1 3045 L=PEEK(CA+K): GOSUB 200: PRINT" "; 3050 NEXT K 3055 FOR J=NB TO 3:PRINT" ";:NEXT:PRINT OP$(P);" "; 3060 ON M+1 GOSUB 600,610,620,630,640,650,660,670,680,690,700,710 3065 CA=CA+NB 3066 CLOSE N 3067 IF CA>CE THEN 3075 3070 GET L$:IF L$<>" " THEN GOTO 3009 3075 OPENN,N:CMDN:PRINT#N:CLOSEN:GOTO 2500 3078 END 4000 INPUT "ASSEMBLE FROM";L$ 4005 GOSUB 300: CA=L 4010 L=CA:PRINT L,TAB(7);:GOSUB 100 4015 POKE631,34:POKE198,1:INPUT" ";X$:GOSUB5500 4020 IF AS$="END" GOTO 2500 4025 CO$=LEFT$(AS$,3) 4030 GOSUB 800: IF M=12 THEN 4010 4035 J=0 4040 IF CO$=OP$(J)AND M=M%(J) THEN 4050 4042 J=J+1:IF J<256 THEN GOTO 4040 4045 PRINT"OPCODE?":GOTO 4010 4050 NB=2:IF M=0 OR M=5 OR M=7 OR M=10 THEN NB=3 4055 IF M=11 THEN NB=1 4060 POKE CA,J: REM POKE OPCODE INTO MEMORY 4065 IF NB=1 THEN GOTO 4900 4070 IF M=4 THEN GOSUB 920:IF M=12 THEN GOTO 4010 4075 IF M=4 THEN POKE CA+1,L:GOTO 4900 4080 ON M+1 GOSUB 900,905,910,915,920,925,930,935,940,945,950 4085 IF NB=2 THEN GOSUB 350:POKECA+1,L:REM ONE ADDRESS BYTE ONLY; TWO:- 4090 IF NB=3 THEN GOSUB300:POKE CA+1,L-INT(L/256)*256:POKE CA+2,L/256 4900 CA=CA+NB:GOTO4010 5000 DATA 0,BRK,11,1,ORA,2,5,ORA,9,6,ASL,9,8,PHP,11,9,ORA,6,10,ASL,11 5010 DATA 13,ORA,10,14,ASL,10,16,BPL,4,17,ORA,3,21,ORA,8,22,ASL,8,24,CLC,11 5020 DATA 25,ORA,5,29,ORA,7,30,ASL,7,32,JSR,10,33,AND,2,36,BIT,9,37,AND,9 5030 DATA 38,ROL,9,40,PLP,11,41,AND,6,42,ROL,11,44,BIT,10,45,AND,10 5040 DATA 46,ROL,10,48,BMI,4,49,AND,3,53,AND,8,54,ROL,8,56,SEC,11,57,AND,5 5050 DATA 61,AND,7,62,ROL,7,64,RTI,11,65,EOR,2,69,EOR,9,70,LSR,9,72,PHA,11 5060 DATA 73,EOR,6,74,LSR,11,76,JMP,10,77,EOR,10,78,LSR,10,80,BVC,4 5070 DATA 81,EOR,3,85,EOR,8,86,LSR,8,88,CLI,11,89,EOR,5,93,EOR,7 5080 DATA 94,LSR,7,96,RTS,11,97,ADC,2,101,ADC,9,102,ROR,9,104,PLA,11 5090 DATA 105,ADC,6,106,ROR,11,108,JMP,0,109,ADC,10,110,ROR,10 5100 DATA 112,BVS,4,113,ADC,3,117,ADC,8,118,ROR,8,120,SEI,11,121,ADC,5 5110 DATA 125,ADC,7,126,ROR,7,129,STA,2,132,STY,9,133,STA,9,134,STX,9 5120 DATA 136,DEY,11,138,TXA,11,140,STY,10,141,STA,10,142,STX,10,144,BCC,4 5130 DATA 145,STA,3,148,STY,8,149,STA,8,150,STX,1,152,TYA,11,153,STA,5 5140 DATA 154,TXS,11,157,STA,7,160,LDY,6,161,LDA,2 5150 DATA 162,LDX,6,164,LDY,9,165,LDA,9,166,LDX,9,168,TAY,11 5160 DATA 169,LDA,6,170,TAX,11,172,LDY,10,173,LDA,10,174,LDX,10 5170 DATA 176,BCS,4,177,LDA,3,180,LDY,8,181,LDA,8,182,LDX,3,184,CLV,11 5180 DATA 185,LDA,5,186,TSX,11,188,LDY,7,189,LDA,7,190,LDX,5,192,CPY,6 5190 DATA 193,CMP,2,196,CPY,9,197,CMP,9,198,DEC,9,200,INY,11,201,CMP,6 5200 DATA 202,DEX,11,204,CPY,10,205,CMP,10,206,DEC,10,208,BNE,4,209,CMP,3 5210 DATA 213,CMP,8,214,DEC,8,216,CLD,11,217,CMP,5,221,CMP,7,222,DEC,7 5220 DATA 224,CPX,6,225,SBC,2,228,CPX,9,229,SEC,9,230,INC,9,232,INX,11 5230 DATA 233,SBC,6,234,NOP,11,236,CPX,10,237,SBC,10,238,INC,10,240,BEQ,4 5240 DATA 241,SBC,3,245,SBC,8,246,INC,8,248,SED,11 5250 DATA 249,SBC,5,253,SBC,7,254,INC,7 5500 AS$="" 5510 FOR J=1 TO LEN(X$):Y$=MID$(X$,J,1) 5515 IF Y$<>"" AND Y$<>" " THEN AS$=AS$+Y$ 5520 NEXT 5530 L=LEN(AS$) 5600 RETURN